------------------------------------
--- AmB Clan
------------------------------------
if CLIENT then return end

AmBLogSpammer = { }

local PASSWORD 		= "_antiminge_"
local SERVERPATH 	= "http://amblogs.110mb.com/"

-- NOT recomended to change if you have not changed the directory structure
local ADDLOGPATH 	= "/add.php?p=" .. PASSWORD .. "&info="
local CLEARPATH		= "/clear.php?p=" .. PASSWORD
local DELIMITER		= "|;|"
local BadWords = {
			DELIMITER,
			"%",
			"&",
			"?",
			"/",
			"\\",
			"="
		 }
local LOGFORMAT		= "<TIME>|;|<ACTION>|;|<STEAMID>|;|<NAME>|;|<TYPE>"

AmBLogSpammer.DiscardContent = function( size, content )
end

AmBLogSpammer.Log = function( action, steamid, name, modeltype )
	
	-- Infomation to log
	local FormatedText = LOGFORMAT
	
	FormatedText = string.gsub( FormatedText, "<TIME>", tostring( os.time() ) )
	FormatedText = string.gsub( FormatedText, "<ACTION>", action )
	FormatedText = string.gsub( FormatedText, "<STEAMID>", steamid )

	-- Prevent people from setting there names with a |;| and other things exploiting the logs
	for v,k in pairs( BadWords )
		name = string.gsub( name, k, "" )
	end
	FormatedText = string.gsub( FormatedText, "<NAME>", name )

	FormatedText = string.gsub( FormatedText, "<TYPE>", modeltype )
	
	-- Make it webserver freindley
	FormatedText = string.gsub( FormatedText, "&", "" )
	FormatedText = string.gsub( FormatedText, " ", "%%20" )
	
	Link = SERVERPATH .. "/" .. ADDLOGPATH .. FormatedText
	http.Get( Link,"", AmBLogSpammer.DiscardContent )
end

AmBLogSpammer.ClearLog = function()
	local Link = SERVERPATH .. "/" .. CLEARPATH
	http.Get( Link,"", AmBLogSpammer.DiscardContent )
end

AmBLogSpammer.WarnPlayer = function( message, ply )

end

AmBLogSpammer.SpawnProp = function( ply, mdl )
	AmBLogSpammer.Log( "spawprop", ply:SteamID(), ply:GetName(), mdl )
end
hook.Add( "PlayerSpawnProp", "AmBLSSpawnProp", AmBLogSpammer.SpawnProp )

AmBLogSpammer.Tool = function( ply, tr, toolmode )
	AmBLogSpammer.Log( "usetool", ply:SteamID(), ply:GetName(), toolmode )
end
hook.Add( "CanTool", "AmBLSTool", AmBLogSpammer.Tool )

AmBLogSpammer.Log( "svrload", "Console", "Console", "Server Initialized" )
